/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.vineatoum.utils;
public class CalculatorLogic {

    // a method defined for performing addition. it takes two double as
    // parameter and returns their add result
    public double add(double a, double b) {
        return a + b;
    }

    // a method defined for performing subtraction. it takes two double as
    // parameter and returns their subtract result
    public double substruct(double a, double b) {
        return a - b;
    }

    // a method defined for performing multiplication. it takes two double as
    // parameter and returns their multiplying result
    public double multiply(double a, double b) {
        return a * b;
    }

    // a method defined for performing Division. it takes two double as
    // parameter and returns their division result. if here happen any
    // situation of division by zero, it will return zero ...here I manually
    // handle exception instead of Java exception handling..
    public double divide(double a, double b) {
        if (b == 0) {
            System.out.println("cant divide by zero");
            return 0;
        } else
            return a / b;
    }

    // this method defined for make string value to double.. its called parsing
    public double stringToDouble(String a) {
        return Double.parseDouble(a);
    }
}